Actionscript - Dropping Multiple Objects Using an Array? [closed]
Posted
by
Eratosthenes
on Game Development
See other posts from Game Development
or by Eratosthenes
Published on 2012-03-26T03:06:26Z
Indexed on
2012/03/26
17:40 UTC
Read the original article
Hit count: 176
animation
|actionscript
Possible Duplicate:
Actionscript - Dropping Multiple Objects Using an Array?
I'm trying to get these fireBalls to drop more often, im not sure if im using Math.random correctly
also, for some reason I'm getting a null reference because I think the fireBalls array waits for one to leave the stage before dropping another one?
this is the relevant code:
var sun:Sun=new Sun
var fireBalls:Array=new Array()
var left:Boolean;
function onEnterFrame(event:Event){
if (left) {
sun.x = sun.x - 15;
}else{
sun.x = sun.x + 15;
}
if (fireBalls.length>0&&fireBalls[0].y>stage.stageHeight){ // Fireballs exit stage
removeChild(fireBalls[0]);
fireBalls.shift();
}
for (var j:int=0; j<fireBalls.length; j++){
fireBalls[j].y=fireBalls[j].y+15;
if (fireBalls[j].y>stage.stageHeight-fireBall.width/2){
}
}
if (Math.random()<.2){ // Fireballs shooting from Sun
var fireBall:FireBall=new FireBall;
fireBall.x=sun.x;
addChild(fireBall);
fireBalls.push(fireBall);
}
}
© Game Development or respective owner